package com.api.tag.unfollow;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.ITagApiService;
import com.zyncro.api.exceptions.ZyncroApiException;

@ContextConfiguration(locations = { "classpath:/tags/tags-context.xml" })
public class UnfollowTag extends AbstractApiTest {

	@Value("#{statictags['user.toUnfollowTag'].appId}")
	private String unfollowTagUserUrn;

	@Value("#{statictags['user.toUnfollowTag'].password}")
	private String unfollowTagUserPassword;

	@Value("#{statictags['category.urn']}")
	private String categoryToUnfollowUrn;

	@Value("#{statictags['location.urn']}")
	private String locationToUnfollowUrn;

	@BeforeClass
	protected void setParameters() throws Exception {

		getApi().login(unfollowTagUserUrn, unfollowTagUserPassword);
	}

	@Test
	public void testUnfollowCategory() throws ZyncroApiException {

		getApi().getService(ITagApiService.class).unfollowTag(categoryToUnfollowUrn);
	}

	@Test
	public void testUnfollowLocation() throws ZyncroApiException {

		getApi().getService(ITagApiService.class).unfollowTag(locationToUnfollowUrn);
	}

	@AfterClass
	public void restoreState() throws ZyncroApiException {

		getApi().getService(ITagApiService.class).followTag(categoryToUnfollowUrn);

		getApi().getService(ITagApiService.class).followTag(locationToUnfollowUrn);
	}
}
